package com.javasm.adminapi.common.exception;


import com.javasm.adminapi.common.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @className: JavasmExceptionAdvice
 * @description:
 * @author: gfs
 * @date: 2025/9/9 15:24
 * @version: 0.1
 * @since: jdk17
 */
@RestControllerAdvice
@Slf4j
public class JavasmExceptionAdvice {


    @ExceptionHandler(JavasmException.class)
    public ExceptionEnum f2(JavasmException e){
        log.warn(e.getMessage());
        ExceptionEnum exceptionEnum = e.getExceptionEnum();
        return exceptionEnum;
    }


    @ExceptionHandler(Exception.class)
    public R f1(Exception e){
        log.error(e.getMessage());
        R r = new R();
        r.setCode(500);
        r.setMsg(e.getMessage());
        return r;
    }


}
